﻿@model KhuyenMaiVang.Areas.Admin.Models.ResUser

@{
    ViewBag.Title = "Sửa thành viên";
    Layout = "~/Areas/Admin/Views/Shared/_AdminLayout.cshtml";
}
@section heading{Sửa thành viên}

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $('#Password').data('val', 'false')
</script>
@using (Html.BeginForm())
{
    @Html.ValidationSummary(false)
    @Html.AntiForgeryToken()
        <div class="editor-field">
            @Html.HiddenFor(model => model.ID)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Username)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Username)
            @Html.ValidationMessageFor(model => model.Username)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Password)
        </div>
        <div class="editor-field">
            @Html.PasswordFor(model => model.Password)
            @Html.ValidationMessageFor(model => model.Password)
        </div>
    
        <div class="editor-label">
            @Html.LabelFor(model => model.PasswordConfirm)
        </div>
        <div class="editor-field">
            @Html.PasswordFor(model => model.PasswordConfirm)
            @Html.ValidationMessageFor(model => model.PasswordConfirm)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Email)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Email)
            @Html.ValidationMessageFor(model => model.Email)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.DisplayName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.DisplayName)
            @Html.ValidationMessageFor(model => model.DisplayName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Avatar)
        </div>
        <div class="editor-field">
            @Html.HiddenFor(model => model.Avatar)
        </div>
        <!-- Ajax upload avatar -->
        <script src="@Url.Content("~/Content/scripts/ajaxupload/fileuploader.js")" type="text/javascript"></script>
        <link href="@Url.Content("~/Content/scripts/ajaxupload/fileuploader.css")" rel="stylesheet" type="text/css" />
        <script type="text/javascript">
            function createUploader() {
                var uploader = new qq.FileUploader({
                    element: document.getElementById('file-uploader'),
                    action: '/Admin/Helper/Upload/type/avatar',
                    debug: true,
                    multiple: false,
                    allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
                    onComplete: function (file, response) {
                        var fullName = "/content/kmvdata/avatars/" + response;
                        $('#previewAvatar').attr('src', fullName);
                        $('#previewAvatar').height(100);
                        $('input[id=Avatar]').val(fullName);
                    }
                });
            }
            window.onload = createUploader;     
        </script>
        <div id="file-uploader">
            
        </div>
        <img alt="" id="previewAvatar" src="@Html.DisplayFor(model => model.Avatar)" height="100px"/>

        <div class="editor-label">
            @Html.LabelFor(model => model.Phone)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Phone)
            @Html.ValidationMessageFor(model => model.Phone)
        </div>
        <div class="editor-field">
            @Html.HiddenFor(model => model.Status)
        </div>
        <div class="editor-field">
            @Html.HiddenFor(model => model.CreatedTime)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.GroupID, "Phân quyền")
        </div>
        <div class="editor-field">
            @Html.DropDownList("GroupID")
            @Html.ValidationMessageFor(model => model.GroupID)
        </div>

        <p>
            <input class="button" type="submit" value="Cập nhật" />
        </p>
}

<div>
    @Html.ActionLink("Quay lại", "Index")
</div>
